From: Keir Fraser Date: Wed, 10 Sep 2008 10:16:26 +0000 (+0100) Subject: CPUIDLE: Avoid remnant LAPIC timer intr while force hpetbroadcast X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14111^2~11 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=789dc790f316debd10fd808a4f13e08c60930d1a;p=xen.git CPUIDLE: Avoid remnant LAPIC timer intr while force hpetbroadcast LAPIC will stop during C3, and resume to work after exit from C3. Considering below case: The LAPIC timer was programmed to expire after 1000us, but CPU enter C3 after 100us and exit C3 at 9xxus. 0us: reprogram_timer(1000us) 100us: entry C3, LAPIC timer stop 9xxus: exit C3 due to unexpected event, LAPIC timer continue running 10xxus: reprogram_timer(1000us), fail due to the past expiring time. ......: no timer softirq raised, no change to LAPIC timer. ......: if entry C3 again, HPET will be forced reprogramed to now+small_slop. ......: if entry C2, no change to LAPIC. 18xxus: LAPIC timer expires unexpectedly if no C3 entries after 10xxus. Signed-off-by: Wei Gang --- diff --git a/xen/arch/x86/hpet.c b/xen/arch/x86/hpet.c index 31028cc2a6..3857cb0af6 100644 --- a/xen/arch/x86/hpet.c +++ b/xen/arch/x86/hpet.c @@ -233,7 +233,15 @@ void hpet_broadcast_exit(void) if ( cpu_test_and_clear(cpu, ch->cpumask) ) { - reprogram_timer(per_cpu(timer_deadline, cpu)); + if ( !reprogram_timer(per_cpu(timer_deadline, cpu)) ) + { + /* + * The deadline must have passed -- trigger timer work now. + * Also cancel any outstanding LAPIC event. + */ + reprogram_timer(0); + raise_softirq(TIMER_SOFTIRQ); + } if ( cpus_empty(ch->cpumask) && ch->next_event != STIME_MAX ) reprogram_hpet_evt_channel(ch, STIME_MAX, 0, 0);